package cn.fengzhilun.javase.day10.ex;

public class Student implements Comparable<Student>{
	private String name;
	
	private int age;
	private Teacher teacher =new Teacher();
	private Parent parent=new Parent();
	
	
	public Student() {
		super();
	}

	

	public Student(String name, int age) {
		super();
		this.name = name;
		this.age = age;
	}



	/**
	 * @return the age
	 */
	public int getAge() {
		return age;
	}



	/**
	 * @param age the age to set
	 */
	public void setAge(int age) {
		this.age = age;
	}



	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Student [name=" + name + ", age=" + age + "]";
	}



	public void study() {
		System.out.println("正在学习");
		parent.onStudy();
		teacher.onStudy();
	}
	
	private void play() {
		System.out.println("正在打游戏");
	}
	//Teacher 老师是内部类
	class Teacher implements Listener{
		private String name="老师";

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}
		private void play() {
			System.out.println("teacher play...");
		}
		@Override
		public void onStudy() {
			System.out.println("好好学习，天天向上");
			
			System.out.println("name:"+Student.this.name);
			System.out.println(age);
			Student.this.play();
		}
		
	}
	
	interface Listener{
		void onStudy() ;
	}
	
	class Parent implements Listener{

		@Override
		public void onStudy() {
			System.out.println("好孩子，零花钱多一点");
		}
	}
//	public int compareTo(Student other) {
//		
//		return (this.getAge()-other.getAge())>0?1:-1;
//		
//		
//	}

	@Override
	public int compareTo(Student other) {
		return this.getAge()-other.getAge();
	}
}
